fuzz: limit input length (#238)
authorRandy <randy408@protonmail.com>
Fri, 6 May 2022 01:49:11 +0000 (03:49 +0200)
committerGitHub <noreply@github.com>
Fri, 6 May 2022 01:49:11 +0000 (21:49 -0400)
Longer inputs can lead to timeouts on oss-fuzz

test/fuzzer.c

index 1e02f3395baa3c6a97288c5baee93e62853743b6..15007c9de773692667b3468c5caa76a8a11d3991 100644 (file)
@@ -5,6 +5,9 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
 {
     if(size < 1) return 0;
 
+    /* Avoid timeout with long inputs */
+    if(size > (64 * 1024)) return 0;
+
     if(data[size-1] != '\0') return 0;
 
     const uint8_t* ptr = data;
@@ -54,7 +57,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
         options = UTF8PROC_STRIPCC;
         memcpy(copy, data, size);
         utf8proc_normalize_utf32(copy, size, options);
-        
+
         options = 0;
         memcpy(copy, data, size);
         utf8proc_normalize_utf32(copy, size, options);